{include file="pub:header" /}
<script>
$(function(){
	$('.J_tablelist').listTable();
	$('.J_preview').preview();
});
/*设置状态*/
function setStatus(id, status) {
	if (!id || id.length == 0)return alert("请选择一条记录");

	$('#myform').attr('action', "{:url('gstate')}");
	$('#state').val(status);
	ajaxpost('myform');
}
/*批量删除*/
function editDel(id) {
	if (!id || id.length == 0)return alert("请选择一条记录");

	$('#myform').attr('action', "{:url('del')}");
	ajaxpost('myform');
}
/*排序*/
function setSort() {
	$('#myform').attr('action', "{:url('gsort')}");
	ajaxpost('myform');
}
</script>
</head>
<body>

	<div class="subnav">
		<div class="content_menu ib_a blue line_x">
            <a href="javascript:;"><span class="pagetitle">【应用管理】</span></a>
            <span>|</span>
			<a class="add fb J_showdialog" href="javascript:;" onclick="openli(this);" data-uri="{:url('goodsedit')}" data-id="169" title="编辑应用"><em>添加应用</em></a>
		</div>
	</div>

	<div class="pad_lr_10">

		<form action="{:url('goods')}" method="get">
		    <input type="hidden" name="state" value="{$state}">
			<table width="100%" cellspacing="0" class="search_form">
				<tbody>
					<tr>
						<td>
							<div class="explain_col">
								应用名称
								<input name="keywords" type="text" class="input-text" size="20" value="{$keywords}">
								<select name="cat"  class="J_cate_select mr10" style="width:120px;">
								  <option value="0">=选择分类=</option>
                                    {volist name="gcat" id="vo"}
                                        <option value="{$vo['id']}"<?php echo $vo['id']==$cat?' selected':'';?>>{$vo['name']}</option>
                                    {/volist}
								  </select>


								发布时间
								<input name="starttime" type="text" size="13" id="d4311" onfocus="WdatePicker({maxDate:'#F{ $dp.$D(\'d4312\')}'})" class="input-text Wdate" value="{$starttime}" readonly>
								至
								<input name="endtime" type="text" size="13" id="d4312" onfocus="WdatePicker({minDate:'#F{ $dp.$D(\'d4311\')}'})" class="input-text Wdate" value="{$endtime}" readonly>
								<input type="submit" class="btn" value="搜索" />
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</form>

<div class="col_tab" style="margin-top:5px;">
		<ul class="J_tabs tab_grid cu_li">
		   {volist name="reviewary" id="vo"}
		   <li<?php echo $key==$state?' class="current"':'' ?>><a href="{:url('goods')}?state={$key}">{$vo}</a></li>
		   {/volist}
		</ul>

		<div class="J_tablelist table_list">
			<form action="" id="myform">
			<input type="hidden" name="state" value="1" id="state">
				<table width="100%" cellspacing="0">

					<thead>
						<tr>
							<th width="40" class="sort_th"><input type="checkbox" name="checkall" class="J_checkall"></th>
							<th width="50" align="left" class="sort_th">缩略图</th>
							<th width="300" align="left" class="sort_th">应用名称</th>
                            <th width="50" align="left" class="sort_th">应用编号</th>
                            <th width="100" class="sort_th">分类</th>
							<th width="50" class="sort_th">状态</th>
							<th class="sort_th">排序</th>
							<th class="sort_th">发布时间</th>
							<th>管理操作</th>
						</tr>
					</thead>


					<tbody>

						{volist name="list" id="vo"}
						<tr>
							<td align="center"><input type="checkbox" name='id[]' class="J_checkitem" value="{$vo['id']}"></td>
							<td><div class="img_border"><img src="{:img_thumb($vo['coverimg'])}" width="32" class="J_preview" data-bimg="{$vo['coverimg']}"></div></td>
							<td>
								{$vo['name']}
								<?php if($vo['description']){ ?>
								<p>{$vo['description']}</p>
								<?php } ?>
							</td>
                            <td align="center"><b>{$vo['id']}</b></td>
                            <td align="center">{$gcat[$vo['cat']]['name']}</td>
							<td align="center"><b><?php echo $vo['state']?'<font color="green">上架中</font>':'<font color="red">下架中</font>';?></b></td>
							<td align="center"><input type="text" style="text-align: center;" class="input-text" size="5" name="sort[{$vo['id']}]" value="{$vo['sort']}"></td>
							<td align="center">{$vo['time']|date="Y-m-d"}</td>
							<td align="center">
								【<a href="javascript:;" onclick="openli(this);" data-uri="{:url('goodsedit',['id'=>$vo['id']])}" data-id="169" title="编辑应用">修改</a>】
								{if condition="$vo['state'] eq 1"}
								  【<a href="javascript:void(0);" onClick="ajaxget('{:url('gstate',['id'=>$vo['id'],'state'=>0])}','确认上架该应用吗?');" title="点击下架">下架</a>】
								{else /}
								  【<a href="javascript:void(0);" onClick="ajaxget('{:url('gstate',['id'=>$vo['id'],'state'=>1])}','确认上架该应用吗?');" title="点击上架"><font color="red">上架</font></a>】
								{/if}
								 【<a href="javascript:void(0);" onClick="ajaxget('{:url('gdel',['id'=>$vo['id']])}','确认删除该应用吗?');" title="点击删除">删除</a>】
							</td>
						</tr>
						{/volist}

						{empty name="list"}
						<tr>
							<td colspan="9" align="center">暂无数据 !</td>
						</tr>
						{/empty}

					</tbody>
				</table>
				</form>
		</div>

       </div>

		<div class="btn_wrap_fixed">
            <label class="select_all mr10"><input type="checkbox" name="checkall" class="J_checkall">全选/取消</label>
            <input type="button" value="批量上架" class="btn" onclick="setStatus($.checkBoxValue('id[]'), 1)"/>
            <input type="button" value="批量下架" class="btn" onclick="setStatus($.checkBoxValue('id[]'), 0)"/>
            <!--<input type="button" value="批量删除" class="btn" onclick="editDel($.checkBoxValue('id[]'))"/>-->
			<input type="button" value="排序" class="btn" onclick="setSort()" />

			<div id="pages">{$list|raw}</div>
		</div>

    </div>

{include file="pub:footer" /}
